package plugin.extend;

import com.intellij.util.ui.ColumnInfo;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.ui.DomCollectionControl;
import org.jetbrains.annotations.NotNull;
import plugin.PluginDomFixedChildDescription;
import plugin.xml.Required;
import plugin.xml.Requireds;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ssrs
 * Date: Created in 2020/9/3 10:47
 * Description:
 */
public class RequiredControl extends DomCollectionControl<Requireds> {

    public RequiredControl(DomElement parentElement, String subTagName, boolean editable, ColumnInfo<Requireds, ?>... columnInfos) {
        super(parentElement, subTagName, editable, columnInfos);
    }

    public static class RequiredRequiredPlugin extends PluginDomFixedChildDescription {
        @NotNull
        @Override
        public List<? extends DomElement> getValues(@NotNull DomElement domElement) {
            Required required = (Required) domElement;
            List<DomElement> list = new ArrayList<>();
            list.add(required.getPlugin());
            return list;
        }
    }

    public static class RequiredVersion extends PluginDomFixedChildDescription {
        @NotNull
        @Override
        public List<? extends DomElement> getValues(@NotNull DomElement domElement) {
            Required required = (Required) domElement;
            List<DomElement> list = new ArrayList<>();
            list.add(required.getVersion());
            return list;
        }
    }
}
